﻿//PlazaTraderHelper.cs
//Copyright (c) 2013 StockSharp LLC, all rights reserved.
//This code module is part of StockSharp library.
//This code is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.
//See the file License.txt for the license details.
//More info on: http://stocksharp.com

namespace StockSharp.Plaza
{
	using System;
	using System.Collections.Generic;
	using System.Linq;

	using Ecng.Collections;

	/// <summary>
	/// Вспомогательный класс для работы с <see cref="PlazaTrader"/>.
	/// </summary>
	public static class PlazaTraderHelper
	{
		/// <summary>
		/// Синхронизировать <see cref="PlazaTrader.Tables"/> со <paramref name="tableIds"/>.
		/// </summary>
		/// <param name="trader">Шлюз к Plaza 2.</param>
		/// <param name="tableIds">Идентификаторы таблиц.</param>
		public static void SyncTables(this PlazaTrader trader, IEnumerable<string> tableIds)
		{
			if (trader == null)
				throw new ArgumentNullException("trader");

			if (tableIds == null)
				throw new ArgumentNullException("tableIds");

			lock (trader.Tables.SyncRoot)
			{
				trader.Tables.Clear();
				trader.Tables.AddRange(tableIds.Select(id => trader.TableRegistry[id]));
			}
		}
	}
}